
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2324. -- [ZJOI2011]营救皮卡丘 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2324: [ZJOI2011]营救皮卡丘</h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>256 MB<br><span class=green>Submit: </span>422&nbsp;&nbsp;<span class=green>Solved: </span>147<br>[<a href='submitpage.php?id=2324'>Submit</a>][<a href='problemstatus.php?id=2324'>Status</a>][<a href='bbs.php?id=2324'>Discuss</a>]</center><h2>Description</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">皮卡丘被火箭队用邪恶的计谋抢走了！这三个坏家伙还给小智留下了赤果果的挑衅！为了皮卡丘，也为了正义，小智和他的朋友们义不容辞的踏上了营救皮卡丘的道路。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">火箭队一共有</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个据点，据点之间存在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">条双向道路。据点分别从<font face="Times New Roman">1</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">标号。小智一行</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">人从真新镇出发，营救被困在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的皮卡丘。为了方便起见，我们将真新镇视为<font face="Times New Roman">0</font><font face="宋体">号据点，一开始</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人都在<font face="Times New Roman">0</font><font face="宋体">号点。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">由于火箭队的重重布防，要想摧毁</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点，必须按照顺序先摧毁<font face="Times New Roman">1</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点，并且，如果</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点没有被摧毁，由于防御的连锁性，小智一行任何一个人进入据点</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，都会被发现，并产生严重后果。因此，在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点被摧毁之前，任何人是不能够经过</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">为了简化问题，我们忽略战斗环节，小智一行任何一个人经过</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点即认为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点被摧毁。被摧毁的据点依然是可以被经过的。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人是可以分头行动的，只要有任何一个人在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点被摧毁之后，经过</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点就被摧毁了。显然的，只要</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点被摧毁，皮卡丘就得救了。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">野外的道路是不安全的，因此小智一行希望在摧毁</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点救出皮卡丘的同时，使得</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人所经过的道路的长度总和最少。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">请你帮助小智设计一个最佳的营救方案吧！</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></div><h2>Input</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行</span><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">包含</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">三个正整数</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。表示一共有</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">+1<font face="宋体">个据点，分别从</font><font face="Times New Roman">0</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">编号，以及</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">条无向边。一开始小智一行共</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人均位于<font face="Times New Roman">0</font><font face="宋体">号点。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">行，每行三个非负整数，第</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">行的整数为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">A</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">B</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">L</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。表示存在一条从</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">A</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点到</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">B</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的长度为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">L</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">的道路。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Output</h2><div class=content><p class="p20" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'"><font face="宋体">仅包含一个整数</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">S</span><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">，为营救皮卡丘所需要经过的最小的道路总和。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata><br />
3 4 2<br />
<br />
0 1 1<br />
<br />
1 2 1<br />
<br />
2 3 100<br />
<br />
0 3 1<br />
<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>3<br />
<br />
【样例说明】<br />
<br />
小智和小霞一起前去营救皮卡丘。在最优方案中，小智先从真新镇前往1号点，接着前往2号据点。当小智成功摧毁2号据点之后，小霞从真新镇出发直接前往3号据点，救出皮卡丘。<br />
<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p><br /><br />
对于10%的数据满足 K = 1，且N = 3，小智将独自前去营救皮卡丘；</p><br />
<p>对于20%的数据满足 K &le; 3，且N &le; 20，被小智单挑剿灭的火箭队加强了防御，增加了据点数；</p><br />
<p>对于40%的数据满足 K &le; 3，且N &le; 100，面对加强的防御，小智拉来了好朋友小霞和小刚，一同前去营救；</p><br />
<p>对于另外20%的数据满足任意一对据点之间均存在道路，并且对任意的0 &le; X,Y,Z &le; N，有不等式L(X,Z) &le; L(X,Y) + L(Y,Z)成立；</p><br />
<p>对于100%的数据满足N &le; 150, M &le; 20 000, 1 &le; K &le; 10, Li &le; 10 000, 保证小智一行一定能够救出皮卡丘。</p><br />
<p>至于为什么K &le; 10，你可以认为最终在小智的号召下，小智，小霞，小刚，小建，小遥，小胜，小光，艾莉丝，天桐，还有去日本旅游的黑猫警长，一同前去大战火箭队。<br /><br />
</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Day2'>Day2</a></p></div><center>[<a href='submitpage.php?id=2324'>Submit</a>][<a href='problemstatus.php?id=2324'>Status</a>][<a href='bbs.php?id=2324'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
